<?php
$title = urldecode($_POST['title']);
$data = urldecode($_POST['data']);
$switch = $_POST['Switch']; // 将 'true' 字符串转换为布尔类型
$configFileName = urldecode($_POST['configFileName']);

$configPath = "./" . $configFileName; // 构建配置文件的路径

$config = file_get_contents($configPath);
$configData = json_decode($config, true);

if (isset($configData['title'])) {
    $configData['title'] = $title;
}
if (isset($configData['data'])) {
    $configData['data'] = $data;
}
if (isset($configData['Switch'])) {
    $configData['Switch'] = $switch;
}

file_put_contents($configPath, json_encode($configData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));

$response = array('status' => 'success');
$responseJson = json_encode($response, JSON_UNESCAPED_UNICODE);
$responseUrlEncoded = urlencode($responseJson);
echo $responseUrlEncoded;
?>
